task main()// :D
{
int a = 0;// <(^.^)>
int trials = 100;//sets number of trials
int minballs = 1000;//sets initial value of minballs(will change throughout trials)
int maxballs = 0;//sets initial value of maxballs (will change throughout trials)
int totalmagnetballs = 0;// sets the total magnet balls found (will change throughout trials)
int ballsprocessed = 50;//sets the amout of balls processed during each trial
for( a = 0; a<trials; a++)
{
int ballcount = 99;//sets the total amount of balls per match
int magnetballcount = 11;//sets the amount of magnet balls per match
int magnetballsfound = 0;//sets the amount of magnet balls found per match
int i = 0;//
int ballnumber =0;//sets which type of ball is found(will be changed throughout trials)
for(i = 0;i <ballsprocessed;i++)
{
ballnumber = random(ballcount);//makes ballnumber a random number between 0 and 99
if (ballnumber < magnetballcount)//if ballnumber is less than 11 it's a magnet ball
{
magnetballcount--;//if magnet ball is found there's one less magnet ball total
magnetballsfound ++;//if magnet ball is found found magnet balls go up by 1
}
ballcount --;//total balls decreased by 1
}
//nxtDisplayTextLine(1, "magnetballs %d", magnetballsfound);
//wait10Msec(100);
if (magnetballsfound < minballs)//if amount of magnet balls found is less than minballs
{
minballs = magnetballsfound;//then minballs is changed to the value of magnetballsfound
}
if (magnetballsfound > maxballs)//if amount of magnet balls found is more than maxballs
{
maxballs = magnetballsfound;//then maxballs is changed to the value of magnetballsfound
}
totalmagnetballs = totalmagnetballs + magnetballsfound;//after trial the totalmagnetballs increase by amount of magnet balls found
}
nxtDisplayTextLine(2, "maxballs %d", maxballs);//displays maxballs on nxt
nxtDisplayTextLine(3, "minballs %d", minballs);//displays minballs on nxt
nxtDisplayTextLine(4, "avg %f", (float)totalmagnetballs/ (float)trials);//displays average magnet balls found each trail
while(true)//makes infinite loop
{
}
}


//                 ___
//               _|___|_|    ( )--------( )
//               <(^.^)>|     | \      / |
//              O-(  )=-O     |o________o|
//                 O O        |__________|hagofenuheb
//
